home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Utilities / Programming / Script Builder 1.0 / Read Me next >
Encoding:
Text File  |  1995-12-12  |  4.0 KB  |  63 lines  |  [TEXT/ttxt]

  1. Script Builder v1.0
  2.             by Gordon Watts (gwatts@fnal.fnal.gov)
  3.  
  4. Script Builder allows you to add Script Editor's compiled scripts to your Code Warrior project.  They are copied into your application as 'scpt' resources.  It required CW7 or later.
  5.  
  6. Suggestions and comments can be directed to me at gwatts@fnal.fnal.gov
  7.  
  8. Installation
  9. Move the file "Script Builder" to the Code Warrior folder "CodeWarrior Plugins" folder.  Quit the Code Warrior IDE if it is open, or CW will not recognize the new plugin.  After starting up, open the "Target" preferences panel.  After "Type:" enter "osas".  Under flags select "launchable", and for Compiler select "Script Builder".  Your done.  You may want to modify your stationary files so you don't have to do this for every new project you create.  You will have to do this for every project you've already created, however.
  10.  
  11. Creating Scripts
  12. Use the Script Editor, that came with the Mac OS, to create scripts, or any other editor that saves compiled scripts.  In the script editor, when you save a script, select the "compiled script" format.
  13.  
  14. One very important thing.  Somewhere in your script you must add the string "RESID=<n>" where <n> is a resource id number (like 50).  For example, here is a script from one of my applications that plays with mosaic hot lists:
  15.  
  16. -- RESID=100 CW plugin will take care of this
  17. tell application "HotList"
  18.     try
  19.         set theFile to (choose file with prompt "Hot List To Import" of type "HOTL")
  20.         display dialog "Got it here " & theFile
  21.         make new Hot List with data theFile
  22.     on error
  23.     end try
  24. end tell
  25.  
  26. when CW builds my app, it will create a script with a resource id of 100.
  27.  
  28. Adding Scripts To The Project
  29. You can now add compiled scripts the same way you might add a resource file or a text file.  You can drag the files onto the project window, or use the Add Files menu command.
  30.  
  31. Compiling the Scripts
  32. CW will attempt to build the file just like any other file in the project.  Script Builder will produce an error if it can't find the compiled script resource ('scpt', id=128) in the file, or it can't find the text "RESID=<n>" in the script.  In CW7, when you get an error, double clicking on the error will open the script file as a text file in the code warrior editor.  Bummer.  I'm thinking this might be fixed in CW8, but I don't know.
  33.  
  34. The compiler output will be 'scpt' resources.  The resources will have the id specified in the string "RESID=", and the name of the file.  So, the above example script is stored in a file called "Import Hotlist", and the built application has a 'scpt' resource, id 100, with the name "Import Hotlist".
  35.  
  36. Using Compiled Scripts
  37. See develop 18 and 19 for the real details.  That is where I pulled all of my stuff.  Basically, you load the script, and then you execute it.
  38.  
  39. I've included two classes in here that I've used to help me out.  These won't compile (I think some debug files are missing) but it should be too much work to get them working.  They are in C++ (if someone wants to give me some pascal snippits, I'll be happy to include them).
  40.  
  41. In my document class definition, I declare the varriable:
  42.  
  43.     GOSAScript        mImportScript;
  44.  
  45. In the document init routine I do:
  46.  
  47.       mImportScript.LoadFromResource ("\pImport Hotlist");
  48.  
  49. Then, in my ObeyCommand method, when I get the the "import hotlist..." command from the user, I do:
  50.  
  51.   mImportScript.Execute ();
  52.  
  53. This may not work for you, but I really like it!
  54.  
  55. Have fun.  This is freeware.  If you have suggestions for other features, let me know -- I do want to keep it simple though!  You can email me at gwatts@fnal.fnal.gov.  This archive can be put on any online service, and can be distributed on any CD without asking me permission as long as the complete archive goes with it.
  56.  
  57.     Cheers,
  58.         Gordon.
  59.  
  60. Email: gwatts@fnal.fnal.gov
  61. Archive contains: Script Builder, Release Notes, GOSAScript.cp, GOSAScrip.h, GOSAID.cp, GOSAID.h, GOSAScriptComponent.cp, GOSAScriptComponent.h
  62.  
  63. Many thanks to the folks at MW who answered several questions on plugins, and to Peter Lewis who writes great software (like Balloon Compiler